<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登陆</title>
    <link type="text/css" rel="stylesheet" href="../plugin/bootstrap-3.3.7-dist/css/bootstrap.css" />
</head>
<body>
<div id="app">
<div class="form-horizontal">
    <div class="form-group">
        <div class="control-label col-md-4">用户名：</div>
        <div class="col-md-8">
            <input class="form-control" type="text" v-model:value="user.username" placeholder="请输入用户名">
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-md-4">邮箱：</div>
        <div class="col-md-8">
            <input class="form-control" type="text" v-model:value="user.email" placeholder="邮箱">
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-md-4">电话：</div>
        <div class="col-md-8">
            <input class="form-control" type="text" v-model:value="user.phone" placeholder="电话">
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-md-4">密码：</div>
        <div class="col-md-8">
            <input class="form-control" type="password" v-model:value="user.password" placeholder="密码">
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-md-4">确认密码：</div>
        <div class="col-md-8">
            <input class="form-control" type="password" v-model:value="user.repassword" placeholder="确认密码">
        </div>
    </div>
    <div class="form-group">
        <div class="control-label col-md-4"></div>
        <div class="col-md-8">
            <button class="btn btn-primary" v-on:click="login">登陆</button>
        </div>
    </div>
</div>
</div>
<script type="text/javascript" src="../js/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../plugin/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<script type="text/javascript" src="../js/core.js"></script>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el:"#app",
        data:{
            user:{
                username:"",
                password:"",
                email:"",
                phone:"",
                repassword:""
            }
        },
        methods: {
            login: function (event) {
                console.log("login"+this.user.username)
                if (this.user.username == "") {
                    return
                }
                CMPostServer("/api/user/register", this.user, function (data) {
                    if (0 == data.code) {
                        window.location = "login.html";
                    } else {
                        alert(data.msg)
                    }
                });
            }
        }
    })
</script>
</body>
</html>